3970 RPORT "Patched at $"&HEX$(N,32)&CHR$(10):NoRpc%=NoRpc%+1
3980 END IF
3990 END IF
4000 END DEFine
4010 :
4020 DEFine PROCedure fixTAS
4030 CLS#4
4040 EA_mask=HEX('003F')
4050 TAS_mask=HEX('FFC0')-HEX('10000')
4060 LINEF_7_inst=HEX('AE00')-HEX('10000')
4070 TAS_inst=HEX('4AC0')
4080 p=0
4090 REPeat Replace_loop
4100 IF p>=fl THEN EXIT Replace_loop
4110 FOR N=1 TO 256
4120 pk=PEEK_W(base+p)
4130 IF ((pk && TAS_mask)=TAS_inst) THEN
4140 ea=pk && EA_mask
4150 SELect ON ea
4160 =0 TO 7 : REMark dn - can handle this!
4170 REMark RPORT HEX$(p,32)&" TAS d"&(ea&&7)
4180 REMark Replace_TAS
4190 =16 TO 23 : REMark (an)
4200 RPORT HEX$(p,32)&" TAS (a"&(ea&&7)&")"
4210 Replace_TAS
4220 =24 TO 31 : REMark (an)+
4230 RPORT HEX$(p,32)&" TAS (a"&(ea&&7)&")+"
4240 Replace_TAS
4250 =32 TO 39 : REMark -(an)
4260 RPORT HEX$(p,32)&" TAS -(a"&(ea&&7)&")"
4270 Replace_TAS
4280 =40 TO 47 : REMark d(an)
4290 RPORT HEX$(p,32)&" TAS "&HEX$(PEEK_W(base+p+2),16)&"(a"&(ea&&7)&")"
4300 Replace_TAS
4310 =48 TO 55 : REMark d(an,a/dn)
4320 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK(base+p+3),8)&"(a"&(ea&&7)&","&("da"(1+(INT(PEEK(base+p+2)/128)&&1)))&INT(PEEK(base+p+2)/16)&&7&"."&("wl"(1+(INT(PEEK(base+p+2)/8)&&1)))&")"
4330 Replace_TAS
4340 =56 : REMark $.w
4350 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK_W(base+p+2),16)
4360 Replace_TAS
4370 =57 : REMark $.l
4380 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK_L(base+p+2),32)
4390 Replace_TAS
4400 =REMAINDER : REMark impossible
4410 REMark ignore illegal address modes
4420 END SELect
4430 IF Rplc$=="Q" THEN NoRpc%=0:EXIT Replace_loop
4440 ELSE
4441 temp$=HEX$(PEEK_L(base+p),32)
4442 IF temp$=="46FC0000" THEN
4443 POKE_L base+p,HEX("027CC0FF"):DISOUT:RPORT "tidying code at $"&HEX$(p,32)&CHR$(10):NoRpc%=NoRpc%+1
4446 END IF
4448 END IF
4450 p=p+2
4460 IF p>=fl THEN EXIT N
4470 END FOR N
4480 IF p>fl THEN
4490 BLOCK#4;100,10,0,0,4
4500 ELSE
4510 BLOCK#4;INT((p/fl)*100),10,0,0,4
4520 END IF
4530 END REPeat Replace_loop
4540 END DEFine
4550 :
4560 DEFine PROCedure Replace_TAS
4570 LOCal get_loop
4580 IF NOT(Rplc$=="a")
4590 DISOUT
4600 Rplc$=WAITKEY$(3,"ynaq")
4610 CLS#5
4620 ELSE
4630 RPORT " replaced."&CHR$(10)
4640 END IF
4650 IF Rplc$=="y" OR Rplc$=="a" THEN
4660 POKE_W base+p,LINEF_7_inst||ea
4670 NoRpc%=NoRpc%+1
4680 END IF
4690 END DEFine
4700 :
4710 DEFine PROCedure treatTAS
4720 REMark Replace TAS instructions in a QL-friendly way.
4730 REMark Extends the code, so may not be reliable with
4740 REMark tasks that assume their own size.
4750 CLS#4
4760 EA_mask=HEX('003F')
4770 TST_mask=HEX('4A00'):BSET_mask=HEX('08C0')
4780 TAS_mask=HEX('FFC0')-HEX('10000')
4790 TAS_inst=HEX('4AC0')
4800 BSR_inst=HEX('6100')
4810 RTS_inst=HEX('4E75')
4820 NOP_inst=HEX('4E71')
4830 LastByte=base+fl
4840 Rplc$=""
4850 p=0:Flg%=0
4860 REPeat Replace_loop
4870 IF p>=fl THEN EXIT Replace_loop
4880 FOR N=1 TO 256
4890 pk=PEEK_W(base+p)
4900 IF ((pk && TAS_mask)=TAS_inst) THEN
4910 ea=pk && EA_mask
4920 SELect ON ea
4930 =0 TO 7 : REMark dn - can handle this!
4940 REMark RPORT HEX$(p,32)&" TAS d"&ea&&7
4950 REMark Treat_ARI
4960 =16 TO 23 : REMark (an)
4970 RPORT HEX$(p,32)&" TAS (a"&(ea&&7)&")"
4980 Treat_ARI
4990 =24 TO 31 : REMark (an)+
5000 RPORT HEX$(p,32)&" TAS (a"&(ea&&7)&")+"
5010 Treat_ARI
5020 =32 TO 39 : REMark -(an)
5030 RPORT HEX$(p,32)&" TAS -(a"&(ea&&7)&")"
5040 Treat_ARI
5050 =40 TO 47 : REMark d(an)
5060 RPORT HEX$(p,32)&" TAS "&HEX$(PEEK_W(base+p+2),16)&"(a"&(ea&&7)&")"
5070 Treat_ARID
5080 =48 TO 55 : REMark d(an,a/dn)
5090 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK(base+p+3),8)&"(a"&(ea&&7)&","&("da"(1+(INT(PEEK(base+p+2)/128)&&1)))&INT(PEEK(base+p+2)/16)&&7&"."&("wl"(1+(INT(PEEK(base+p+2)/8)&&1)))&")"
5100 Treat_ARID
5110 =56 : REMark $.w
5120 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK_W(base+p+2),16)
5130 Treat_ARID
5140 =57 : REMark $.l
5150 RPORT HEX$(p,32)&" TAS $"&HEX$(PEEK_W(base+p+2),32)
5160 Treat_ABSL
5170 =REMAINDER : REMark impossible ea
5180 REMark ignore illegal address modes
5190 END SELect
5200 IF Rplc$=="Q" OR Flg%=-1 THEN NoRpc%=0:EXIT Replace_loop
5210 ELSE
5211 temp$=HEX$(PEEK_L(base+p),32)
5212 IF temp$=="46FC0000" THEN
5213 POKE_L base+p,HEX("027CC0FF"):DISOUT:RPORT "tidying code at $"&HEX$(p,32)&CHR$(10):NoRpc%=NoRpc%+1
5216 END IF
5218 END IF
5220 p=p+2
5230 IF p>=fl THEN EXIT N
5240 END FOR N
5250 IF p>fl THEN
5260 BLOCK#4;100,10,0,0,4
5270 ELSE
5280 BLOCK#4;INT((p/fl)*100),10,0,0,4
5290 END IF
5300 END REPeat Replace_loop
5310 END DEFine
5320 :
5330 DEFine PROCedure Treat_ARI
5340 LOCal disp,get_loop
5350 disp=LastByte-(base+p+2)
5360 IF NOT(Rplc$=="a")
5370 DISOUT
5380 Rplc$=WAITKEY$(3,"ynaq")
5390 CLS#5
5400 END IF
5410 IF Rplc$=="y" OR Rplc$=="a" THEN
5420 IF disp>126 THEN
5430 RPORT " ERROR: OFFSET TOO LARGE"&CHR$(10):Flg%=-1